package com.example.myapplication;

public class Computer {
    //属性
    private String cpu;//cpu
    private String show;//显示器
    private String mainboard;//主板
    private String shubiao;//鼠标
    private String keys;//键盘

    public  Computer(Buider buider) {//外部对象
        this.cpu = buider.cpu;
        this.show = buider.show;
        this.mainboard = buider.mainboard;
        this.shubiao = buider.shubiao;
        this.keys = buider.keys;
    }

    @Override
    public String toString() {//打印
        return "Computer{" +
                "cpu='" + cpu + '\'' +
                ", show='" + show + '\'' +
                ", mainboard='" + mainboard + '\'' +
                ", shubiao='" + shubiao + '\'' +
                ", keys='" + keys + '\'' +
                '}';
    }

    public static class Buider {
        //必须属性
        private String cpu;//cpu
        private String show;//显示器
        private String mainboard;//主板
        //非必须属性
        private String shubiao="我是鼠标";//鼠标
        private String keys="我是键盘";;//键盘
        public Buider(String cpu, String show, String mainboard) {
            this.cpu = cpu;//cpu
            this.show = show;//显示器
            this.mainboard = mainboard;//主板
        }
        public Buider shubiao(String shubiao) {
            this.shubiao = shubiao;
            return this;
        }
        public Buider keys(String keys) {
            this.keys = keys;
            return this;
        }
        public Computer build(){
            return new Computer(this);//返回给外部对象
        };
    }
}
